﻿// Fill out your copyright notice in the Description page of Project Settings.


#include "UMG/MainUIWidget.h"

#include "Components/ProgressBar.h"
#include "Kismet/GameplayStatics.h"

bool UMainUIWidget::Initialize()
{
	if (!Super::Initialize())
	{
		return false;
	}

	ACharacter* PlayerCharacter = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
	if (PlayerCharacter)
	{
		Player = Cast<APlayerCharacter>(PlayerCharacter);
	}
	
	HealthBar->PercentDelegate.BindUFunction(this, FName("GetHealthProgress"));
	BossHealthBar->PercentDelegate.BindUFunction(this, FName("GetBossHealthProgress"));
	return true;
}

float UMainUIWidget::GetHealthProgress()
{
	if (Player)
	{
		return Player->GetHealthProgress();
	}
	return 0.0f;
}

void UMainUIWidget::PlayBloodScreenAnim()
{
	PlayAnimation(BloodScreenAnim);
}

float UMainUIWidget::GetBossHealthProgress()
{
	if(Boss)
	{
		return Boss->GetHealthProgress();
	}
	return 0.0f;
}
